#include <std.h>
#include <log.h>
#include <tsk.h>
#include <stdio.h>
#include <stdlib.h>

#include "hpi.h"
#include "flash_emif.h"
#include "gpio.h"
#include "ddr.h"
#include "tmr.h"
#include <C64.h>

#include "dsp_bios_testcfg.h"

#define TESTING_EMIFA 1

Void main()
{
  CSL_Status     stat;

  LOG_printf(&trace, "Starting test");

  C64_enableIER(C64_EINT4);
  stat = hpi_init();
  if (stat == CSL_SOK)
    printf ("\n----HPI: Initializing complete----\n\n");
  else
    {
      printf ("\nHPI: Can't Initialize\n");
      return;
    }

  stat = ddr_init();
  if (stat == CSL_SOK)
    printf ("\n----DDR: Initializing complete----\n\n");
  else
    {
      printf ("\nDDR: Can't Initialize\n");
      exit(-1);
    }

  stat = timer0_init();
  if (stat == CSL_SOK)
    printf ("\n----Timer init complete ----\n\n");
  else
    {
      printf ("\nTimer: Can't Initialize\n");
      exit(-1);
    }

  stat = gpio_init();
    if (stat == CSL_SOK)
      printf ("\n----GPIO init complete ----\n\n");
    else
      {
        printf ("\nGPIO : Can't Initialize\n");
        exit(-1);
      }

#if !TESTING_EMIFA
  stat = emifa_init();
  if (stat == CSL_SOK)
    printf ("\n----EMIFA init complete ----\n\n");
  else
    {
      printf ("\nEMIFA : Can't Initialize\n");
      exit(-1);
    }
#else
  flash_test();
#endif

  return;
}
